setData
open fun setData(@Nullable dataMimeType: String, @Nullable dataUri: Uri): NotificationCompat.MessagingStyle.Message(source)
Sets a binary blob of data and an associated MIME type for a message. In the case where the platform doesn't support the MIME type, the original text provided in the constructor will be used.
Return
this object for method chaining
Parameters
dataMimeType
The MIME type of the content. See isMimeTypeSupported for a list of supported image MIME types.
dataUri
The uri containing the content whose type is given by the MIME type.
Notification Listeners including the System UI need permission to access the data the Uri points to. The recommended ways to do this are:
- Store the data in your own ContentProvider, making sure that other apps have the correct permission to access your provider. The preferred mechanism for providing access is to use per-URI permissions which are temporary and only grant access to the receiving application. An easy way to create a ContentProvider like this is to use the FileProvider helper class.
- Use the system MediaStore. The MediaStore is primarily aimed at video, audio and image MIME types, however beginning with Android 3.0 (API level 11) it can also store non-media types (see MediaStore.Files for more info). Files can be inserted into the MediaStore using scanFile() after which a content:// style Uri suitable for sharing is passed to the provided onScanCompleted() callback. Note that once added to the system MediaStore the content is accessible to any app on the device.